home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir42 / c7105.zip / BRWSGRPS.TPX < prev    next >
Text File  |  1994-03-02  |  50KB  |  1,039 lines

  1. #!┌───────────────────────────┤Template Segment├───────────┬─────────────────┐
  2. #!│                              BrwsGrps.TPX              │Version: 3007.105│
  3. #!├───────────────────────────────┤Contents├───────────────┴─────────────────┤
  4. #!│Structure             Type       Description                              │
  5. #!│────────────────────  ─────────  ─────────────────────────────────────────│
  6. #!│SetBrowseSymbols      GROUP                                               │
  7. #!│AddFixedListLines     GROUP                                               │
  8. #!│BeginBrowse           GROUP                                               │
  9. #!│FillKeyValues         GROUP                                               │
  10. #!│BrowseErrorCheck      GROUP                                               │
  11. #!│ClearFileFields       GROUP                                               │
  12. #!│TotalBeforeUpdate     GROUP                                               │
  13. #!│TotalAfterUpdate      GROUP                                               │
  14. #!│AddTotalValues        GROUP                                               │
  15. #!│UpdateTotalValues     GROUP                                               │
  16. #!│ClearTotalValues      GROUP                                               │
  17. #!│SetupKeyRangeFields   GROUP                                               │
  18. #!│SaveRangeFields       GROUP                                               │
  19. #!│RestoreRangeFields    GROUP                                               │
  20. #!│CheckKeyRangeFields   GROUP                                               │
  21. #!│RangeComparison       GROUP                                               │
  22. #!│EditCodeInsert        GROUP                                               │
  23. #!│EditCodeChange        GROUP                                               │
  24. #!│EditCodeDelete        GROUP                                               │
  25. #!│EditCodeSelect        GROUP                                               │
  26. #!│EditCodeExit          GROUP                                               │
  27. #!│EditCodeCancel        GROUP                                               │
  28. #!│EditCodeLocator       GROUP                                               │
  29. #!│EditCodeList          GROUP                                               │
  30. #!│ClearRecordHigh       GROUP                                               │
  31. #!│ClearRecordLow        GROUP                                               │
  32. #!│LookupValidateCode    GROUP                                               │
  33. #!│LookupRecord          GROUP                                               │
  34. #!│IsUpdateSuccessful    GROUP                                               │
  35. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  36. #!│Version   Comments                                                        │
  37. #!│────────  ────────────────────────────────────────────────────────────────│
  38. #!│3007.000  Release of CDD3 version 3007 templates                          │
  39. #!│3007.101  Repaired %SetBrowseSymbols GROUP                                │
  40. #!│          Repaired %UpdateTotalValues GROUP                               │
  41. #!│3007.102  Repaired %EditCodeInsert GROUP                                  │
  42. #!│          Repaired %EditCodeChange GROUP                                  │
  43. #!│          Repaired %EditCodeDelete GROUP                                  │
  44. #!│3007.103  Repaired %EditCodeList GROUP                                    │
  45. #!│          Repaired %LookupValidateCode #GROUP                             │
  46. #!│          Added %EditCodeLocator #GROUP                                   │
  47. #!│3007.105  Repaired %EditCodeList GROUP                                    │
  48. #!└──────────────────────────────────────────────────────────────────────────┘
  49. #!
  50. #GROUP(%SetBrowseSymbols)
  51. #!
  52. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  53. #!│                            SetBrowseSymbols            │Version: 3007.101│
  54. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  55. #!│Purpose:      Determine operating parameters of a Browse-type procedure   │
  56. #!│Called From:  Browse,Validate,Lookup,Select                               │
  57. #!│Assumptions:  None                                                        │
  58. #!│Inserts:      None                                                        │
  59. #!│Symbols Set:  Most Browse Symbols                                         │
  60. #!│Notes:        None                                                        │
  61. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  62. #!│Version   Comments                                                        │
  63. #!│────────  ────────────────────────────────────────────────────────────────│
  64. #!│3007.000  Release of CDD3 version 3007 templates                          │
  65. #!│3007.101  Changed Hot Fields code to exclude the Locator from displayed   │
  66. #!│          fields and to add pre-?List fields                              │
  67. #!└──────────────────────────────────────────────────────────────────────────┘
  68. #!
  69.   #SET(%FirstEntryField,%Null)
  70.   #SET(%PreListEntry,%Null)
  71.   #SET(%UpdateButtonsExist,%Null)
  72.   #SET(%KeyboardInsert,%Null)
  73.   #SET(%KeyboardChange,%Null)
  74.   #SET(%KeyboardDelete,%Null)
  75.   #SET(%KeyboardSelect,%Null)
  76.   #SET(%InsertExists,%Null)
  77.   #SET(%ChangeExists,%Null)
  78.   #SET(%DeleteExists,%Null)
  79.   #SET(%SelectExists,%Null)
  80.   #SET(%ExitExists,%Null)
  81.   #SET(%FilterExists,%Null)
  82.   #SET(%HotKeyExists,%Null)
  83.   #SET(%ScreenFldSetupExists,%Null)
  84.   #SET(%ScreenFldEditExists,%Null)
  85.   #SET(%ControlRelatedFiles,%Null)
  86.   #SET(%TotalExists,%Null)
  87.   #SET(%TotalFormulas,%Null)
  88.   #SET(%FirstHotField,%Null)
  89.   #SET(%SecondHotField,%Null)
  90.   #SET(%ThirdHotField,%Null)
  91.   #SET(%FourthHotField,%Null)
  92.   #SET(%FifthHotField,%Null)
  93.   #SET(%SixthHotField,%Null)
  94.   #FIX(%File,%Primary)
  95.   #FOR(%HotKey)
  96.     #SET(%HotKeyExists,'YES')
  97.     #BREAK
  98.   #ENDFOR
  99.   #FOR(%Formula)
  100.     #IF(UPPER(%FormulaClass) = 'FILTER')
  101.       #SET(%FilterExists, 'YES')
  102.     #ENDIF
  103.   #ENDFOR
  104.   #IF(%RecordFilter)
  105.     #SET(%FilterExists, 'YES')
  106.   #ENDIF
  107.   #SET(%FirstEntryFound,%Null)
  108.   #FOR(%ScreenField)
  109.     #SET(%ScreenFieldExists,'YES')
  110.     #IF(%FirstEntryFound = %Null)
  111.       #SET(%FirstEntryField, (%FirstEntryField + 1))
  112.       #IF(%ScreenFieldSkip <> 'Y')
  113.         #SET(%FirstEntryFound,'YES')
  114.       #ENDIF
  115.     #ENDIF
  116.     #IF(%ScreenFieldType = 'BUTTON')
  117.       #IF(UPPER(%ScreenField) = '?INSERT')
  118.         #SET(%UpdateButtonsExist, 'YES')
  119.         #SET(%InsertExists, 'YES')
  120.         #SET(%KeyboardInsert,'YES')
  121.       #ELSIF(UPPER(%ScreenField) = '?CHANGE')
  122.         #SET(%UpdateButtonsExist, 'YES')
  123.         #SET(%ChangeExists, 'YES')
  124.         #SET(%KeyboardChange,'YES')
  125.       #ELSIF(UPPER(%ScreenField) = '?DELETE')
  126.         #SET(%UpdateButtonsExist, 'YES')
  127.         #SET(%DeleteExists, 'YES')
  128.         #SET(%KeyboardDelete,'YES')
  129.       #ELSIF(UPPER(%ScreenField) = '?SELECT')
  130.         #SET(%UpdateButtonsExist, 'YES')
  131.         #SET(%SelectExists, 'YES')
  132.         #SET(%KeyboardSelect,'YES')
  133.       #ELSIF(UPPER(%ScreenField) = '?EXIT')
  134.         #SET(%ExitExists, 'YES')
  135.       #ENDIF
  136.     #ENDIF
  137.   #ENDFOR
  138.   #IF(%UpdateButtonsExist=%Null)
  139.     #SET(%KeyboardInsert,'YES')
  140.     #SET(%KeyboardChange,'YES')
  141.     #SET(%KeyboardDelete,'YES')
  142.     #SET(%KeyboardSelect,'YES')
  143.   #ENDIF
  144.   #IF(%ScreenFieldSetup)
  145.     #SET(%ScreenFldSetupExists,'YES')
  146.   #ENDIF
  147.   #IF(%ScreenFieldEdit)
  148.     #SET(%ScreenFldEditExists,'YES')
  149.   #ENDIF
  150.   #SET(%FixRows, '0')
  151.   #FIX(%ScreenField,'?List')
  152.   #FOR(%ScreenFieldFix)
  153.     #SET(%FixRows, (%FixRows + 1))
  154.   #ENDFOR
  155.   #FOR(%Formula)
  156.     #IF(UPPER(%FormulaClass) = 'SUM')
  157.       #SET(%TotalFormulas,'TRUE')
  158.       #BREAK
  159.     #ELSIF(UPPER(%FormulaClass) = 'AVG')
  160.       #SET(%TotalFormulas,'TRUE')
  161.       #BREAK
  162.     #ELSIF(UPPER(%FormulaClass) = 'CNT')
  163.       #SET(%TotalFormulas,'TRUE')
  164.       #BREAK
  165.     #ENDIF
  166.   #ENDFOR
  167.   #IF(%TotalsOn OR %TotalFormulas)
  168.     #SET(%TotalExists, 'TRUE')
  169.     #IF(%KeyRangeField)
  170.       #FOR(%ScreenField)
  171.         #IF(UPPER(%ScreenField)='?LIST')
  172.           #BREAK
  173.         #ENDIF
  174.         #IF(%ScreenFieldType='ENTRY')
  175.           #IF(%ScreenFieldSkip <> 'Y')
  176.             #IF(UPPER(%ScreenFieldUse)<>UPPER(%Locator))
  177.               #SET(%PreListEntry,'TRUE')
  178.               #BREAK
  179.             #ENDIF
  180.           #ENDIF
  181.         #ENDIF
  182.       #ENDFOR
  183.     #ENDIF
  184.   #ENDIF
  185.   #IF(%HotBar)                                   #! IF updating screen on key
  186.     #SET(%ListFound,%Null)                       #! CLEAR Flag (Last Found?)
  187.     #SET(%LocatorFound,%Null)                    #! CLEAR Flag (Locator Found?)
  188.     #FOR(%ScreenField)                           #! Cycle through screen fields
  189.       #IF(%ListFound=%Null)                      #! IF ?List not processed
  190.         #IF(UPPER(%ScreenField)='?LIST')         #! IF %ScreenField is ?List
  191.           #SET(%ListFound,'TRUE')                #! SET the Flag
  192.         #ELSE                                    #! ELSE (IF %ScreenField...)
  193.           #IF(%FirstHotField)                    #! IF we've got a start
  194.             #SET(%SecondHotField,%ScreenField)   #! Get an end
  195.           #ELSE                                  #! ELSE (If we've got...)
  196.             #SET(%FirstHotField,%ScreenField)    #! Get a start
  197.           #ENDIF                                 #! END (If we've got...)
  198.         #ENDIF                                   #! END (If %ScreenField...)
  199.       #ELSIF(%LocatorFound=%Null)                #! ELSIF Locator not processed
  200.         #IF(UPPER(%ScreenFieldUse)=UPPER(%Locator)) #! IF %ScreenFieldUse is %Locator
  201.           #SET(%LocatorFound,'TRUE')             #! SET the Flag
  202.         #ELSE                                    #! ELSE (IF %ScreenField...)
  203.           #IF(%ThirdHotField)                    #! IF we've got a start
  204.             #SET(%FourthHotField,%ScreenField)   #! Get an end
  205.           #ELSE                                  #! ELSE (If we've got...)
  206.             #SET(%ThirdHotField,%ScreenField)    #! Get a start
  207.           #ENDIF                                 #! END (If we've got...)
  208.         #ENDIF                                   #! END (If %ScreenField...)
  209.       #ELSE                                      #! ELSE (Past Locator)
  210.         #IF(%FifthHotField)                      #! IF we've got a start
  211.           #SET(%SixthHotField,%ScreenField)      #! Get an end
  212.         #ELSE                                    #! ELSE (If we've got...)
  213.           #SET(%FifthHotField,%ScreenField)      #! Get a start
  214.         #ENDIF                                   #! END (If we've got...)
  215.       #ENDIF                                     #! END (IF List not...)
  216.     #ENDFOR                                      #! END (cycle through screen...)
  217.   #ENDIF                                         #! END (IF updating screen...)
  218. #!                                               #!
  219. #!***************************************************************************
  220. #GROUP(%AddFixedListLines)                   #!Group to add any QUEUE fixed
  221. #FIX(%ScreenField,'?List')                   #! lines to the QUEUE.
  222. #FOR(%ScreenFieldFix)
  223. Queue = %ScreenFieldFix                      #<!Add fixed listbox line
  224. ADD(Queue)                                     ! to the QUEUE
  225. #ENDFOR
  226. #!***************************************************************************
  227. #GROUP(%BeginBrowse)
  228. #IF(%NoMemo)
  229.   #IF(%Locator)                                #!Conditionally initialize
  230.     #IF(%IncrementalLocator)
  231.       #IF(%HotBar)                             #! the browse session manager
  232. BeginBrowse(?List,?%Locator,1,1,1) #<!Begin a browse session
  233.       #ELSE
  234. BeginBrowse(?List,?%Locator,,1,1)              #<!Begin a browse session
  235.       #ENDIF
  236.     #ELSE
  237.       #IF(%HotBar)                             #! the browse session manager
  238. BeginBrowse(?List,?%Locator,1,,1)              #<!Begin a browse session
  239.       #ELSE
  240. BeginBrowse(?List,?%Locator,,,1)               #<!Begin a browse session
  241.       #ENDIF
  242.     #ENDIF
  243.   #ELSE
  244.     #IF(%HotBar)
  245. BeginBrowse(?List,,1,,1)                       #<!Begin a browse session
  246.     #ELSE
  247. BeginBrowse(?List,,,,1)                        #<!Begin a browse session
  248.     #ENDIF
  249.   #ENDIF
  250. #ELSE
  251.   #IF(%Locator)                                #!Conditionally initialize
  252.     #IF(%IncrementalLocator)
  253.       #IF(%HotBar)                             #! the browse session manager
  254. BeginBrowse(?List,?%Locator,1,1) #<!Begin a browse session
  255.       #ELSE
  256. BeginBrowse(?List,?%Locator,,1)                #<!Begin a browse session
  257.       #ENDIF
  258.     #ELSE
  259.       #IF(%HotBar)                             #! the browse session manager
  260. BeginBrowse(?List,?%Locator,1)                 #<!Begin a browse session
  261.       #ELSE
  262. BeginBrowse(?List,?%Locator)                   #<!Begin a browse session
  263.       #ENDIF
  264.     #ENDIF
  265.   #ELSE
  266.     #IF(%HotBar)
  267. BeginBrowse(?List,,1)                          #<!Begin a browse session
  268.     #ELSE
  269. BeginBrowse(?List)                             #<!Begin a browse session
  270.     #ENDIF
  271.   #ENDIF
  272. #ENDIF
  273. #!***************************************************************************
  274. #GROUP(%FillKeyValues)
  275. #FOR(%KeyField)
  276. QUE::%KeyField =%KeyField                      #<!   Fill any key fields
  277. #ENDFOR
  278. #!
  279. #!***************************************************************************
  280. #GROUP(%BrowseErrorCheck)
  281. #!
  282. #IF(%Primary = %Null)
  283.   #SET(%ErrorMessage, (%Procedure & ' ERROR: No file has been chosen for this procedure.'))
  284.   #ERROR(%ErrorMessage)
  285.   #SET(%ErrorMessage, ' A file must be selected for this procedure.')
  286.   #ERROR(%ErrorMessage)
  287. #ENDIF
  288. #IF(%PrimaryKey = %Null)
  289.   #SET(%ErrorMessage, (%Procedure & ' ERROR: No Access Key has been chosen for this procedure.'))
  290.   #ERROR(%ErrorMessage)
  291.   #SET(%ErrorMessage, ' An Access Key must be identified on the File Schematic.')
  292.   #ERROR(%ErrorMessage)
  293. #ENDIF
  294. #IF(%KeyRangeField)
  295.   #IF(UPPER(%KeyRangeField) = UPPER(%RangeValue))
  296.     #SET(%ErrorMessage, (%Procedure & ' ERROR: Range Limit Field and Range Value fields must'))
  297.     #ERROR(%ErrorMessage)
  298.     #SET(%ErrorMessage, ' be separate fields.')
  299.     #ERROR(%ErrorMessage)
  300.   #ENDIF
  301. #ENDIF
  302. #FIX(%File,%Primary)
  303. #IF(%DisplayKey)
  304.   #FIX(%Key,%DisplayKey)
  305. #ELSE
  306.   #FIX(%Key,%PrimaryKey)
  307. #ENDIF
  308. #IF(%Locator)
  309.   #SET(%FieldFound,%Null)
  310.   #FOR(%KeyField)
  311.     #IF(UPPER(%KeyField) = UPPER(%Locator))
  312.       #SET(%FieldFound,'Yes')
  313.       #BREAK
  314.     #ENDIF
  315.   #ENDFOR
  316.   #IF(%FieldFound = %Null)
  317.     #SET(%ErrorMessage, (%Procedure & ' ERROR: the Locator Field must be a component of'))
  318.     #ERROR(%ErrorMessage)
  319.     #SET(%ErrorMessage, (' the ' & %Key & ' key.'))
  320.     #ERROR(%ErrorMessage)
  321.   #ENDIF
  322. #ENDIF
  323. #IF((UPPER(%ProcedureTemplate)='BROWSE' OR UPPER(%ProcedureTemplate)='SELECT'))
  324.   #FIX(%Key,%PrimaryKey)
  325. #ELSE
  326.   #IF(%DisplayKey)
  327.     #FIX(%Key,%DisplayKey)
  328.   #ELSE
  329.     #FIX(%Key,%PrimaryKey)
  330.   #ENDIF
  331. #ENDIF
  332. #IF(%KeyRangeField)
  333.   #SET(%FieldFound,%Null)
  334.   #FOR(%KeyField)
  335.     #IF(UPPER(%KeyField) = UPPER(%KeyRangeField))
  336.       #SET(%FieldFound,'Yes')
  337.       #BREAK
  338.     #ENDIF
  339.   #ENDFOR
  340.   #IF(%FieldFound = %Null)
  341.     #SET(%ErrorMessage, (%Procedure & ' ERROR: Key Range Limit Field must be a component of the'))
  342.     #ERROR(%ErrorMessage)
  343.     #SET(%ErrorMessage, ' File Access Key')
  344.     #ERROR(%ErrorMessage)
  345.   #ENDIF
  346. #ENDIF
  347. #!
  348. #!***************************************************************************
  349. #GROUP(%ClearFileFields)
  350. #!
  351. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  352. #!│                            ClearFileFields             │Version: 3007.101│
  353. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  354. #!│Purpose:      Clear out a File's record structure and memos.              │
  355. #!│Called From:  Various INSERTS from BROWSE type procedures                 │
  356. #!│Assumptions:  That %File is FIXed                                         │
  357. #!│Inserts:      None                                                        │
  358. #!│Symbols Set:  None                                                        │
  359. #!│Notes:        None                                                        │
  360. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  361. #!│Version   Comments                                                        │
  362. #!│────────  ────────────────────────────────────────────────────────────────│
  363. #!│3007.000  Release of CDD3 version 3007 templates                          │
  364. #!│3007.101  Modified to support the clearing of BINARY memos to low values  │
  365. #!│          CLEAR(%Field,-1).  Before, all memos were cleared to 0.         │
  366. #!└──────────────────────────────────────────────────────────────────────────┘
  367. #!
  368. CLEAR(%FilePre:Record)                           #<! CLEAR Record buffer
  369. #FOR(%FileMemo)                                  #! Cycle through each memo
  370.   #FIX(%Field,%FileMemo)                         #! FIX the field to the memo
  371.   #IF(%FieldMemoImage='Y')                       #! IF a Binary memo
  372. CLEAR(%Field,-1)                                 #<! CLEAR BINARY Memo buffer
  373.   #ELSE                                          #! ELSE (IF not a Binary...)
  374. CLEAR(%Field)                                    #<! CLEAR Memo buffer
  375.   #ENDIF                                         #! END (IF a Binary...)
  376. #ENDFOR                                          #! END (Cycle through each...)
  377. #!***************************************************************************
  378. #GROUP(%TotalBeforeUpdate)                       #!Group Containing Browse totals
  379. #IF(%TotalExists)                                #! If we are doing totals
  380. #INSERT(%GetSecondaryRecords)                    #! Lookup any secondaries
  381.   #IF(%TotalFormulas)                            #! If Formulas compute totals
  382.     #IF(%KeyboardChange OR %KeyboardDelete)      #! IF Change or Delete Active
  383. CASE UpdateMode                                  #<! Check how update is called
  384.       #IF(%KeyboardChange AND %KeyboardDelete)
  385. OF ChangeRecord OROF DeleteRecord                #<! Changing or Deleting
  386.       #ELSIF(%KeyboardChange)
  387. OF ChangeRecord                                  #<! Changing
  388.       #ELSE
  389. OF DeleteRecord                                  #<! Deleting
  390.       #ENDIF
  391.       #FOR(%Formula)                             #! Cycle through the formulas
  392.         #IF(%FormulaType = 'COMPUTED')           #! If using COMPUTED formula
  393.           #IF((UPPER(%FormulaClass)='SUM' OR UPPER(%FormulaClass)='AVG'))
  394.   Old::%Formula$ = %FormulaComputation           #<! TOTAL:%FormulaDescription
  395.           #ENDIF
  396.           #IF((UPPER(%FormulaClass)='CNT' OR UPPER(%FormulaClass)='AVG'))
  397.   Old::%Formula# = 1                             #<! TOTAL:%FormulaDescription
  398.           #ENDIF
  399.         #ELSE                                    #! otherwise (CONDITION formula)
  400.           #IF((UPPER(%FormulaClass)='SUM' OR UPPER(%FormulaClass)='AVG'))
  401.   Old::%Formula$ = 0                             #! If Average or Counting
  402.           #ENDIF
  403.           #IF((UPPER(%FormulaClass)='CNT' OR UPPER(%FormulaClass)='AVG'))
  404.   Old::%Formula# = 0                             #! If Average or Counting
  405.           #ENDIF
  406.   IF %FormulaCondition                           #<! TOTAL:%FormulaDescription
  407.           #IF((UPPER(%FormulaClass)='SUM' OR UPPER(%FormulaClass)='AVG'))
  408.     Old::%Formula$ = %FormulaTrue                #! If Average or Counting
  409.           #ENDIF
  410.           #IF((UPPER(%FormulaClass)='CNT' OR UPPER(%FormulaClass)='AVG'))
  411.     Old::%Formula# = 1                           #! If Average or Counting
  412.           #ENDIF
  413.           #IF(%FormulaFalse)                     #! If there is a FALSE value
  414.   ELSE                                           #<! otherwise (FALSE)
  415.             #IF((UPPER(%FormulaClass)='SUM' OR UPPER(%FormulaClass)='AVG'))
  416.     Old::%Formula$ = %FormulaFalse               #! If Average or Counting
  417.             #ENDIF
  418.             #IF((UPPER(%FormulaClass)='CNT' OR UPPER(%FormulaClass)='AVG'))
  419.     Old::%Formula# = 1                           #! If Average or Counting
  420.             #ENDIF
  421.           #ENDIF
  422.   END                                            #<! END (If condition is true)
  423.         #ENDIF                                   #! ENDIF (FormulaClass...)
  424.       #ENDFOR                                    #! ENDFOR (Formula...)
  425. END                                              #<! END (CASE KEYCODE()...)
  426.     #ENDIF                                       #! END (If Change or ...)
  427.   #ENDIF                                         #! END (If Formulas...)
  428. #ENDIF                                           #! ENDIF (TotalsExist...)
  429. #!***************************************************************************
  430. #GROUP(%TotalAfterUpdate)
  431. #IF(%TotalExists)
  432. #INSERT(%GetSecondaryRecords)
  433.   #IF(%TotalFormulas)                            #! If Formulas compute totals
  434. IF UpdateSuccessful
  435.     #IF(%KeyboardChange OR %KeyboardDelete)      #! IF Change or Delete Active
  436.       #IF(%KeyboardChange AND %KeyboardDelete)
  437.   IF UpdateMode = ChangeRecord OR UpdateMode = DeleteRecord
  438.       #ELSIF(%KeyboardChange)
  439.   IF UpdateMode = ChangeRecord
  440.       #ELSE
  441.   IF UpdateMode = DeleteRecord
  442.       #ENDIF
  443.       #FOR(%Formula)
  444.       #IF((UPPER(%FormulaClass) = 'AVG' OR UPPER(%FormulaClass)='CNT'))
  445.     %Formula# -= Old::%Formula#
  446.         #ENDIF
  447.         #IF((UPPER(%FormulaClass) = 'SUM' OR UPPER(%FormulaClass)='AVG'))
  448.     %Formula$ -= Old::%Formula$
  449.         #ENDIF
  450.       #ENDFOR
  451.   END
  452.     #ENDIF
  453.     #IF(%KeyboardChange OR %KeyboardInsert)      #! IF Change or Delete Active
  454.       #IF(%KeyboardChange AND %KeyboardInsert)
  455.   IF UpdateMode = ChangeRecord OR UpdateMode = AddRecord
  456.       #ELSIF(%KeyboardChange)
  457.   IF UpdateMode = ChangeRecord
  458.       #ELSE
  459.   IF UpdateMode = AddRecord                      #!If Changing or Adding
  460.       #ENDIF
  461.     LOOP
  462.       #IF(%KeyRangeField)                          #!If using range limits
  463.       #INSERT(%RangeComparison)
  464.         BREAK
  465.       END
  466.       #ENDIF
  467.       #IF(%FilterExists)
  468.         #IF(%RecordFilter)
  469.       IF ~(%RecordFilter)                        #<!If Filter condition not met
  470.         BREAK
  471.       END
  472.         #ENDIF
  473.         #FOR(%Formula)
  474.           #IF(UPPER(%FormulaClass) = 'FILTER')
  475.             #IF(%FormulaType <> 'COMPUTED')
  476.       IF ~(%FormulaCondition)                    #<!If Filter condition not met
  477.         BREAK
  478.       END                                          !End IF
  479.             #ELSE
  480.       IF ~(%FormulaComputation)                  #<!If Filter condition not met
  481.         BREAK
  482.       END                                          !End IF
  483.             #ENDIF
  484.           #ENDIF
  485.         #ENDFOR
  486.       #ENDIF
  487.       #INSERT(%AddTotalValues)
  488.       BREAK
  489.     END
  490.   END
  491.     #ENDIF
  492. END
  493. #INSERT(%UpdateTotalValues)
  494.   #ENDIF                                         #! END (If Formulas...)
  495. #ENDIF
  496. #!***************************************************************************
  497. #GROUP(%AddTotalValues)                          #! Adding values to totals
  498. #FOR(%Formula)                                   #! FOR each Formula
  499.   #IF(%FormulaType = 'COMPUTED')                 #! If COMPUTED formula
  500.     #IF((UPPER(%FormulaClass) = 'CNT' OR UPPER(%FormulaClass)='AVG'))
  501. %Formula# += 1                                   #<!TOTAL:%FormulaDescription
  502.     #ENDIF                                       #! ENDIF (Count or Avg)
  503.     #IF((UPPER(%FormulaClass) = 'SUM' OR UPPER(%FormulaClass)='AVG'))
  504. %Formula$ += %FormulaComputation                 #<!TOTAL:%FormulaDescription
  505.     #ENDIF                                       #! ENDIF (Sum or Avg)
  506.   #ELSE                                          #! If CONDITIONAL formula
  507. IF %FormulaCondition                             #<!TOTAL:%FormulaDescription
  508.     #IF((UPPER(%FormulaClass) = 'CNT' OR UPPER(%FormulaClass)='AVG'))
  509.   %Formula# += 1                                 #<!TOTAL:%FormulaDescription
  510.     #ENDIF                                       #! ENDIF (Count or Avg)
  511.     #IF((UPPER(%FormulaClass) = 'SUM' OR UPPER(%FormulaClass)='AVG'))
  512.   %Formula$ += %FormulaTrue                      #<!TOTAL:%FormulaDescription
  513.     #ENDIF                                       #! ENDIF (Sum or Avg)
  514.     #IF(%FormulaFalse)                           #! IF the formula has FALSE val
  515. ELSE                                             #<! IF the condition is FALSE
  516.       #IF((UPPER(%FormulaClass) = 'CNT' OR UPPER(%FormulaClass)='AVG'))
  517.   %Formula# += 1                                 #<! TOTAL:%FormulaDescription
  518.       #ENDIF                                     #! ENDIF (Count or Avg)
  519.       #IF((UPPER(%FormulaClass) = 'SUM' OR UPPER(%FormulaClass)='AVG'))
  520.   %Formula$ += %FormulaFalse                     #<! TOTAL:%FormulaDescription
  521.       #ENDIF                                     #! ENDIF (Sum or Avg)
  522.     #ENDIF                                       #! ENDIF (False condition...)
  523. END                                              #<! END (IF Condition...)
  524.   #ENDIF                                         #! ENDIF (Conditional formula)
  525. #ENDFOR                                          #! END (For Formula...)
  526. #!***************************************************************************
  527. #GROUP(%UpdateTotalValues)                       #! Updates Totals and screen
  528. #!
  529. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  530. #!│                           UpdateTotalValues            │Version: 3007.101│
  531. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  532. #!│Purpose:      Fill Total formula fields from the accumulation fields      │
  533. #!│Called From:  Browse,Validate,Lookup,Select                               │
  534. #!│Assumptions:  That the GROUP will be called only if totals exist          │
  535. #!│Inserts:      None                                                        │
  536. #!│Symbols Set:  None                                                        │
  537. #!│Notes:        None                                                        │
  538. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  539. #!│Version   Comments                                                        │
  540. #!│────────  ────────────────────────────────────────────────────────────────│
  541. #!│3007.000  Release of CDD3 version 3007 templates                          │
  542. #!│3007.101  Repaired code to handle divide by zero on COUNT totals          │
  543. #!└──────────────────────────────────────────────────────────────────────────┘
  544. #!
  545. #FOR(%Formula)                                   #! FOR each formula
  546.   #IF(UPPER(%FormulaClass) = 'SUM')              #! IF a SUM formula
  547. %Formula = %Formula$                             #<! Move sum to variable
  548.   #ELSIF(UPPER(%FormulaClass) = 'AVG')           #! If Average formula
  549. IF %Formula#                                     #<! IF not divide by zero
  550.   %Formula = %Formula$/%Formula#                 #<! Move average to variable
  551. ELSE                                             #<! ELSE (IF not divide...)
  552.   %Formula = 0                                   #<! Clear variable
  553. END                                              #<! END (If not divide...)
  554.   #ELSIF(UPPER(%FormulaClass) = 'CNT')           #! If Count formula
  555. %Formula = %Formula#                             #<! Move count to variable
  556.   #ENDIF                                         #! ENDIF (FormulaClass...)
  557. #ENDFOR                                          #! ENDFOR (Formula...)
  558. #!***************************************************************************
  559. #GROUP(%ClearTotalValues)                        #! Clears Totals and screen
  560. #FOR(%Formula)                                   #! FOR each formula
  561.   #IF(UPPER(%FormulaClass) = 'SUM')              #! IF a SUM formula
  562. %Formula$ = 0                                    #<! Clear variable
  563.   #ELSIF(UPPER(%FormulaClass) = 'AVG')           #! If Average formula
  564. %Formula$ = 0                                    #<! Clear variable
  565. %Formula# = 0                                    #<! Clear variable
  566.   #ELSIF(UPPER(%FormulaClass) = 'CNT')           #! If Count formula
  567. %Formula# = 0                                    #<! Clear variable
  568.   #ENDIF                                         #! ENDIF (FormulaClass...)
  569. #ENDFOR                                          #! ENDFOR (Formula...)
  570. #!***************************************************************************
  571. #GROUP(%SetupKeyRangeFields)
  572. #SET(%RangeSaveFields,%Null)
  573. #SET(%RangeRestoreFields,%Null)
  574. #SET(%RangeRestoreAll,%Null)
  575. #SET(%BreakAfterGenerate,%Null)
  576. #IF(%KeyRangeField)                              #!If range limit prompt
  577.   #IF(%TotalExists)
  578. SAV::RangeValueChanged BYTE
  579.   #ENDIF
  580.   #FIX(%File,%Primary)                           #!Fix to procedure's primary
  581.   #FIX(%Key,%PrimaryKey)                         #!Fix to primary access key
  582.   #FOR(%KeyField)                                #!For all key components
  583.     #SET(%RangeSaveFields,(%RangeSaveFields+1))
  584.     #IF(upper(%KeyField) = upper(%KeyRangeField))#!If on the range field
  585.       #SET(%GenerateSaveValues,%Null)
  586.       #SET(%BreakAfterGenerate,'TRUE')
  587.       #IF((UPPER(%RangeValue)=UPPER(%KeyField))) #!If a range value is given
  588.         #SET(%GenerateSaveValues,'TRUE')
  589.       #ELSIF(%RangeValue)
  590.       #ELSE
  591.         #SET(%GenerateSaveValues,'TRUE')
  592.       #ENDIF
  593.     #ELSE
  594.       #SET(%GenerateSaveValues,'TRUE')
  595.     #ENDIF
  596.     #IF(%GenerateSaveValues)                     #!Do Nothing, otherwise
  597.       #SET(%RangeRestoreFields,(%RangeRestoreFields+1))
  598.       #FIX(%Field,%KeyField)                     #!Fix to component of key
  599.       #IF(%FieldType = 'GROUP')                  #!If component is a group
  600. SAV::%KeyField  LIKE(%KeyField),PRE(SAV)         #<!Save Range Limit Group
  601.       #ELSE                                      #!Else component NOT a group
  602. SAV::%KeyField  LIKE(%KeyField)                  #<!Save Range Limit Field
  603.       #ENDIF                                     #!EndIf component is a group
  604.     #ENDIF                                       #!EndIf %RangeValue not used
  605.     #IF(%BreakAfterGenerate)
  606.       #BREAK
  607.     #ENDIF
  608.   #ENDFOR                                        #!EndFor all key components
  609.   #IF(%RangeSaveFields=%RangeRestoreFields)
  610.     #SET(%RangeRestoreAll,'TRUE')
  611.   #ENDIF
  612. #ENDIF                                           #!EndIf range limit prompt
  613. #!***************************************************************************
  614. #GROUP(%SaveRangeFields)
  615. #IF(%KeyRangeField)                              #!If using range limits
  616.   #SET(%FieldsToSave,%Null)
  617.   #FOR(%KeyField)                                #!for all key components
  618.     #IF(%RangeRestoreAll OR (%FieldsToSave<%RangeRestoreFields))
  619. SAV::%KeyField = %KeyField                       #<! Save Key Field
  620.     #ENDIF
  621.     #SET(%FieldsToSave,(%FieldsToSave+1))
  622.     #IF(%FieldsToSave=%RangeRestoreFields)
  623.       #BREAK
  624.     #ENDIF
  625.   #ENDFOR                                        #!EndFor KeyFields
  626. #ENDIF                                           #!EndIF KeyRangeField
  627. #!***************************************************************************
  628. #GROUP(%RestoreRangeFields)
  629. #IF(%KeyRangeField)                              #!If using range limits
  630.   #SET(%FieldsToSave,%Null)
  631.   #FOR(%KeyField)                                #!for all key components
  632.     #IF(%RangeRestoreAll)
  633. %KeyField = SAV::%KeyField                       #<! Restore Key Field
  634.     #ELSE
  635.       #IF(%FieldsToSave<%RangeRestoreFields)
  636. %KeyField = SAV::%KeyField                       #<! Restore Key Field
  637.       #ELSE
  638. %KeyField = %RangeValue                          #<! Restore Range Value
  639.       #ENDIF
  640.     #ENDIF
  641.     #SET(%FieldsToSave,(%FieldsToSave+1))
  642.     #IF(%FieldsToSave=%RangeSaveFields)
  643.       #BREAK
  644.     #ENDIF
  645.   #ENDFOR                                        #!EndFor KeyFields
  646. #ENDIF                                           #!EndIF KeyRangeField
  647. #!***************************************************************************
  648. #GROUP(%CheckKeyRangeFields)
  649. #IF(%KeyRangeField)                              #!If using range limits
  650.   #INSERT(%RangeComparison)
  651.   PREVIOUS(%Primary)                             #<! Signal build
  652.   #INSERT(%ClearFileFields)                      #!Clear for screen fields
  653.   #INSERT(%RestoreRangeFields)                   #!Restore range values
  654.   CYCLE                                          #<! Cycle
  655. END                                              #<! End IF
  656. #ENDIF                                           #!EndIF KeyRangeField
  657. #!***************************************************************************
  658. #GROUP(%RangeComparison)
  659. #SET(%IfWritten,%Null)                           #!Clear the %Found flag
  660. #SET(%FieldsToSave,%Null)
  661. #FOR(%KeyField)                                  #!for all key components
  662.   #IF((%RangeRestoreAll OR (%FieldsToSave<%RangeRestoreFields)))
  663.     #IF(%KeyNoCase)
  664.       #SET(%Comparison,('(UPPER(' & %KeyField & ') <> UPPER(SAV::' & %KeyField & '))'))
  665.     #ELSE
  666.       #SET(%Comparison,(%KeyField & ' <> SAV::' & %KeyField ))
  667.     #ENDIF
  668.   #ELSE
  669.     #IF(%KeyNoCase)
  670.       #SET(%Comparison,('(UPPER(' & %KeyField & ') <> UPPER(' & %RangeValue & '))'))
  671.     #ELSE
  672.       #SET(%Comparison,(%KeyField & ' <> ' & %RangeValue))
  673.     #ENDIF
  674.   #ENDIF
  675.   #SET(%FieldsToSave,(%FieldsToSave+1))
  676.   #SET(%LastComparison,%Null)
  677.   #IF(%FieldsToSave=%RangeSaveFields)
  678.     #SET(%LastComparison,'TRUE')
  679.   #ENDIF
  680.   #IF(%LastComparison)
  681.     #IF(%IfWritten)
  682. OR %Comparison
  683.     #ELSE
  684. IF %Comparison
  685.       #SET(%IfWritten,'TRUE')
  686.     #ENDIF
  687.     #BREAK
  688.   #ELSE
  689.     #IF(%IfWritten)
  690. OR %Comparison |
  691.     #ELSE
  692. IF %Comparison |
  693.       #SET(%IfWritten,'TRUE')
  694.     #ENDIF
  695.   #ENDIF
  696. #ENDFOR                                         #!EndFor KeyFields
  697. #!***************************************************************************
  698. #GROUP(%EditCodeInsert)
  699. #!
  700. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  701. #!│                             EditCodeInsert             │Version: 3007.103│
  702. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  703. #!│Purpose:      Generate code for ?Insert Button on Browse procedures       │
  704. #!│Called From:  Any BROWSE type procedure                                   │
  705. #!│Assumptions:  That %ScreenField is FIXed to the ?Insert field             │
  706. #!│Inserts:      ClearFileFields                                             │
  707. #!│              RestoreRangeFields                                          │
  708. #!│Symbols Set:  None                                                        │
  709. #!│Notes:        None                                                        │
  710. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  711. #!│Version   Comments                                                        │
  712. #!│────────  ────────────────────────────────────────────────────────────────│
  713. #!│3007.000  Release of CDD3 version 3007 templates                          │
  714. #!│3007.102  Added assignment to UpdateMode to allow updating of totals      │
  715. #!│3007.103  Remove SELECT(?List) from GROUP (Added to UpdateProcedure)      │
  716. #!└──────────────────────────────────────────────────────────────────────────┘
  717. #!
  718. #IF(%UpdateProc)
  719. OF ?Insert                                       !Process the Insert Button
  720.   #IF(%ScreenFieldEdit)
  721.   %ScreenFieldEdit                             #<! Insert button Edit Routine
  722.   #ENDIF
  723.   #INSERT(%ClearFileFields)
  724.   #INSERT(%RestoreRangeFields)
  725.   UpdateMode = AddRecord
  726.   SETKEYCODE(InsKey)                             ! Set action to Insert
  727.   Do UpdateProcedure                             ! Call the update procedure
  728. #ENDIF
  729. #!***************************************************************************
  730. #GROUP(%EditCodeChange)
  731. #!
  732. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  733. #!│                             EditCodeChange             │Version: 3007.103│
  734. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  735. #!│Purpose:      Generate code for ?Change Button on Browse procedures       │
  736. #!│Called From:  Any BROWSE type procedure                                   │
  737. #!│Assumptions:  That %ScreenField is FIXed to the ?Change field             │
  738. #!│Inserts:      None                                                        │
  739. #!│Symbols Set:  None                                                        │
  740. #!│Notes:        None                                                        │
  741. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  742. #!│Version   Comments                                                        │
  743. #!│────────  ────────────────────────────────────────────────────────────────│
  744. #!│3007.000  Release of CDD3 version 3007 templates                          │
  745. #!│3007.102  Added assignment to UpdateMode to allow updating of totals      │
  746. #!│3007.103  Remove SELECT(?List) from GROUP (Added to UpdateProcedure)      │
  747. #!└──────────────────────────────────────────────────────────────────────────┘
  748. #!
  749. #IF(%UpdateProc)
  750. OF ?Change                                       !Process the Change Button
  751.   #IF(%ScreenFieldEdit)
  752.   %ScreenFieldEdit                             #<! Change button Edit Routine
  753.   #ENDIF
  754.   UpdateMode = ChangeRecord
  755.   SETKEYCODE(EnterKey)                           ! Set action to Change
  756.   Do UpdateProcedure                             ! Call the update procedure
  757. #ENDIF
  758. #!***************************************************************************
  759. #GROUP(%EditCodeDelete)
  760. #!
  761. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  762. #!│                             EditCodeDelete             │Version: 3007.103│
  763. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  764. #!│Purpose:      Generate code for ?Delete Button on Browse procedures       │
  765. #!│Called From:  Any BROWSE type procedure                                   │
  766. #!│Assumptions:  That %ScreenField is FIXed to the ?Delete field             │
  767. #!│Inserts:      None                                                        │
  768. #!│Symbols Set:  None                                                        │
  769. #!│Notes:        None                                                        │
  770. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  771. #!│Version   Comments                                                        │
  772. #!│────────  ────────────────────────────────────────────────────────────────│
  773. #!│3007.000  Release of CDD3 version 3007 templates                          │
  774. #!│3007.102  Added assignment to UpdateMode to allow updating of totals      │
  775. #!│3007.103  Remove SELECT(?List) from GROUP (Added to UpdateProcedure)      │
  776. #!└──────────────────────────────────────────────────────────────────────────┘
  777. #!
  778. #IF(%UpdateProc)
  779. OF ?Delete                                       !Process the Delete Button
  780.   #IF(%ScreenFieldEdit)
  781.   %ScreenFieldEdit                             #<! Delete button Edit Routine
  782.   #ENDIF
  783.   UpdateMode = DeleteRecord
  784.   SETKEYCODE(DelKey)                             ! Set action to Delete
  785.   DO UpdateProcedure                             ! Call the update procedure
  786. #ENDIF
  787. #!***************************************************************************
  788. #GROUP(%EditCodeSelect)
  789. OF ?Select
  790.   #IF(%ScreenFieldEdit)
  791.   %ScreenFieldEdit                             #<! Exit button Edit Routine
  792.   #ENDIF
  793.   #IF(%KeyboardSelect)
  794.   SETKEYCODE(EnterKey)
  795.   #ENDIF
  796.   DO ProcedureReturn
  797. #!***************************************************************************
  798. #GROUP(%EditCodeExit)
  799. OF ?Exit                                         !Process the Exit button
  800.   #IF(%ScreenFieldEdit)
  801.     %ScreenFieldEdit                           #<! Exit button Edit Routine
  802.   #ENDIF
  803.   #IF(%KeyboardSelect)
  804.   IF CalledAsLookup
  805.     SETKEYCODE(EscKey)
  806.     GET(%Primary,0)
  807.     #FIX(%File,%Primary)
  808.     CLEAR(%FilePre:Record,0)
  809.   END
  810.   #ENDIF
  811.   DO ProcedureReturn
  812. #!***************************************************************************
  813. #GROUP(%EditCodeCancel)
  814. OF ?Cancel                                       !Process the Exit button
  815.   #IF(%ScreenFieldEdit)
  816.     %ScreenFieldEdit                           #<! Exit button Edit Routine
  817.   #ENDIF
  818.   #IF(%KeyboardSelect)
  819.   IF CalledAsLookup
  820.     SETKEYCODE(EscKey)
  821.     GET(%Primary,0)
  822.     #FIX(%File,%Primary)
  823.     CLEAR(%FilePre:Record,0)
  824.   END
  825.   #ENDIF
  826.   DO ProcedureReturn
  827. #!***************************************************************************
  828. #GROUP(%EditCodeLocator)
  829. #!
  830. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  831. #!│                             EditCodeLocator            │Version: 3007.103│
  832. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  833. #!│Purpose:      Process CASE FIELD() of ?Locator code                       │
  834. #!│Called From:  ALL Browse-Based Procedures                                 │
  835. #!│Assumptions:  None                                                        │
  836. #!│Inserts:      None                                                        │
  837. #!│Symbols Set:  None                                                        │
  838. #!│Notes:        None                                                        │
  839. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  840. #!│Version   Comments                                                        │
  841. #!│────────  ────────────────────────────────────────────────────────────────│
  842. #!│3007.103  Added during 3007.103 Template Release                          │
  843. #!└──────────────────────────────────────────────────────────────────────────┘
  844. #!
  845. OF ?%Locator                                     !Process the Locator
  846.   #IF(%ScreenFieldEdit)
  847.     %ScreenFieldEdit                           #<! Exit button Edit Routine
  848.   #ENDIF
  849. #!***************************************************************************
  850. #GROUP(%EditCodeList)
  851. #!
  852. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  853. #!│                              EditCodeList              │Version: 3007.105│
  854. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  855. #!│Purpose:      Generates "OF ?List" code in Browse CASE Field() code       │
  856. #!│Called From:  Browse-type procedures                                      │
  857. #!│Assumptions:  None                                                        │
  858. #!│Inserts:      None                                                        │
  859. #!│Symbols Set:  None                                                        │
  860. #!│Notes:        None                                                        │
  861. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  862. #!│Version   Comments                                                        │
  863. #!│────────  ────────────────────────────────────────────────────────────────│
  864. #!│3007.000  Release of CDD3 version 3007 templates                          │
  865. #!│3007.103  Repaired code for %KeyboardSelect and no %UpdateProc            │
  866. #!│3007.105  Repaired handling of KEYCODE() = CtrlEnter (now we issue        │
  867. #!│          SETKEYCODE(EnterKey) to tell the form that we're editing.       │
  868. #!└──────────────────────────────────────────────────────────────────────────┘
  869. #!
  870. #IF(%UpdateProc)
  871. OF ?List                                         !Process the list field
  872.   CASE KEYCODE()                                 ! Jump to keycode routine
  873.   #IF(%KeyboardInsert)
  874.   OF InsKey                                      ! For the insert key
  875.     #INSERT(%ClearFileFields)
  876.     #INSERT(%RestoreRangeFields)
  877.     UpdateMode = AddRecord
  878.     DO UpdateProcedure                           !  Call the update procedure
  879.   #ENDIF
  880.   #IF(%KeyboardDelete)
  881.   OF DelKey                                      ! For the delete key
  882.     UpdateMode = DeleteRecord
  883.     DO UpdateProcedure                           !  Call the update procedure
  884.   #ENDIF
  885.   #IF(%KeyboardSelect)
  886.   OF EnterKey
  887.   OROF MouseLeft2
  888.     #IF((UPPER(%ProcedureTemplate)='BROWSE' OR UPPER(%ProcedureTemplate)='SELECT'))
  889.     IF CalledAsLookup
  890.       SETKEYCODE(EnterKey)
  891.       DO ProcedureReturn
  892.     ELSE
  893.       UpdateMode = ChangeRecord
  894.       DO UpdateProcedure                         !  Call the update procedure
  895.     END
  896.     #ELSE
  897.     #INSERT(%LookupValidateCode)
  898.     #ENDIF
  899.   OF CtrlEnter
  900.     IF CalledAsLookup
  901.       SETKEYCODE(EnterKey)
  902.       UpdateMode = ChangeRecord
  903.       DO UpdateProcedure                         !  Call the update procedure
  904.     END
  905.   #ELSIF(%KeyboardChange)
  906.   OF EnterKey                                    ! Or the enter key
  907.   OROF MouseLeft2                                ! Or a double mouse click
  908.     UpdateMode = ChangeRecord
  909.     DO UpdateProcedure                           !  Call the update procedure
  910.   #ENDIF
  911.   END                                            ! End CASE
  912. #ELSIF(%KeyboardSelect)
  913. OF ?List                                         !Process the list field
  914.   #IF((UPPER(%ProcedureTemplate)='BROWSE' OR UPPER(%ProcedureTemplate)='SELECT'))
  915.   IF CalledAsLookup
  916.     IF KEYCODE() = MouseLeft2 or KEYCODE() = EnterKey
  917.       SETKEYCODE(EnterKey)
  918.       DO ProcedureReturn
  919.     END
  920.   END
  921.   #ELSE
  922.   #INSERT(%LookupValidateCode)
  923.   #ENDIF
  924. #ENDIF
  925. #!***************************************************************************
  926. #GROUP(%ClearRecordHigh)
  927. CLEAR(%FilePre:Record,1)
  928. #FIX(%Key,%PrimaryKey)
  929. #FOR(%KeyField)
  930.   #IF(%KeyFieldSequence='DESCENDING')
  931. CLEAR(%KeyField,-1)
  932.   #ENDIF
  933. #ENDFOR
  934. #!***************************************************************************
  935. #GROUP(%ClearRecordLow)
  936. CLEAR(%FilePre:Record,-1)
  937. #FIX(%Key,%PrimaryKey)
  938. #FOR(%KeyField)
  939.   #IF(%KeyFieldSequence='DESCENDING')
  940. CLEAR(%KeyField,1)
  941.   #ENDIF
  942. #ENDFOR
  943. #!***************************************************************************
  944. #GROUP(%LookupValidateCode)
  945. #!
  946. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  947. #!│                           LookupValidateCode           │Version: 3007.103│
  948. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  949. #!│Purpose:      Generate code for Validate and Lookup Procedures            │
  950. #!│Called From:  EditCodeList GROUP                                          │
  951. #!│Assumptions:  None                                                        │
  952. #!│Inserts:      None                                                        │
  953. #!│Symbols Set:  None                                                        │
  954. #!│Notes:        None                                                        │
  955. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  956. #!│Version   Comments                                                        │
  957. #!│────────  ────────────────────────────────────────────────────────────────│
  958. #!│3007.000  Release of CDD3 version 3007 templates                          │
  959. #!│3007.103  Added support for SAV::PullDownOpened for Lookup and Validate.  │
  960. #!│          This support was added because any screen and pulldown needs to │
  961. #!│          be closed so CHANGE only affect the calling screen.             │
  962. #!└──────────────────────────────────────────────────────────────────────────┘
  963. #!
  964. #IF(%ScreenFieldEdit)
  965. %ScreenFieldEdit                                 #<!Select button Edit Routine
  966. #ENDIF
  967. #IF(%Pulldown)                                   #!If a Pulldown exists
  968. IF SAV::PullDownOpened
  969.   CLOSE(%Pulldown)                               #<!Close the Pulldown
  970.   SAV::PullDownOpened = False
  971. END
  972. #ENDIF
  973. CLOSE(%Screen)                                   !Close the screen
  974. #IF((UPPER(%ProcedureTemplate)='VALIDATE'))
  975. SELECT(?)                                        !Select the same field
  976. #ENDIF
  977. CHANGE(SELECTED(),%LookupField)                  !Change to New Value
  978. PRESS(TabKey)                                    !  and a tab key
  979. DO ProcedureReturn                               !Return to caller
  980. #!
  981. #!***************************************************************************
  982. #GROUP(%LookupRecord)                           #!Group to Lookup a record
  983. #IF(%FromLookup)
  984.   #IF(%LookupPicture)
  985. DeformatString = CONTENTS(SELECTED())          #<! Fill the Key Value
  986.   #ELSE
  987. %LookupField = CONTENTS(SELECTED())            #<! Fill the Key Value
  988.   #ENDIF
  989. #ELSE
  990.   #IF(%LookupPicture)
  991. DeformatString = CONTENTS(FIELD())             #<! Fill the Key Value
  992.   #ELSE
  993. %LookupField = CONTENTS(FIELD())               #<! Fill the Key Value
  994.   #ENDIF
  995. #ENDIF
  996. #IF(%LookupPicture)
  997. %LookupField = DEFORMAT(DeformatString,%LookupPicture)
  998. #ENDIF
  999. GET(%Primary,%LookupKey)                       #<! Get the matching record
  1000. IF ~ERRORCODE()                                #<! If found then return
  1001.   DO ProcedureReturn
  1002. END
  1003. #!***************************************************************************
  1004. #GROUP(%IsUpdateSuccessful)
  1005. UpdateSuccessful = True
  1006. #IF(%KeyboardDelete)
  1007. IF POSITION(%Primary)
  1008.   IF UpdateMode = DeleteRecord
  1009.     UpdateSuccessful = False
  1010.   END
  1011.   #IF(%KeyboardChange OR %KeyboardInsert)
  1012. ELSE
  1013.     #IF(%KeyboardChange AND %KeyboardInsert)
  1014.   IF UpdateMode = ChangeRecord OR UpdateMode = AddRecord
  1015.     #ELSIF(%KeyboardChange)
  1016.   IF UpdateMode = ChangeRecord
  1017.     #ELSE
  1018.   IF UpdateMode = AddRecord                      #!If Changing or Adding
  1019.     #ENDIF
  1020.     UpdateSuccessful = False
  1021.   END
  1022.   #ENDIF
  1023. END
  1024. #ELSIF(%KeyboardChange OR %KeyboardInsert)
  1025. IF NOT POSITION(%Primary)
  1026.   #IF(%KeyboardChange AND %KeyboardInsert)
  1027.   IF UpdateMode = ChangeRecord OR UpdateMode = AddRecord
  1028.   #ELSIF(%KeyboardChange)
  1029.   IF UpdateMode = ChangeRecord
  1030.   #ELSE
  1031.   IF UpdateMode = AddRecord                      #!If Changing or Adding
  1032.   #ENDIF
  1033.     UpdateSuccessful = False
  1034.   END
  1035. END
  1036. #ENDIF
  1037. #!***************************************************************************
  1038. #CHAIN('ChldGrps.tpx')
  1039.